package com.ternnetwork.core.notice.repository;


import com.ternnetwork.core.notice.entity.Notice;
import com.ternnetwork.persistence.repository.BaseRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;

import java.util.List;

public interface NoticeRepository extends BaseRepository<Notice, Long> {

    @Modifying
    @Query("update  Notice t set t.category=null where t.category.id=?1")
    Integer updateByDeleteCategory(Long categoryId);

    @Query("from Notice t where t.publishedCode=?1 ")
    List<Notice> findAllByPublishedCode(String publishedCode);


    @Query("select count(1) from Notice where  deleted=false")
    Long countAll();

}
